/******************************************************************************
 * SVN­Version­Information:
 * ­­­­­­­­­­­­­­­­­­­­­­­­---------------------
 * $LastChangedRevision: 130 $
 * $LastChangedBy: SD $
 * $LastChangedDate: 2009-06-23 17:42:49 +0200 (Tue, 23 Jun 2009) $
 * $HeadURL: svn://lvis10.fbm.fht-stuttgart.de/common/Common/src/de/hft_stuttgart/botwar/common/models/NewRobotInfo.java $
 ******************************************************************************/
package de.hft_stuttgart.botwar.common.models;

import java.io.Serializable;

/**
 * Class to save a robot width player.saveRobot(NewRobotInfo)
 * @author pmv-mail@gmx.de
 */
public class NewRobotInfo implements Serializable {

    private final String robotName;
    private final String armament;
    private final String chassis;
    private final String shield;

    /**
     * New robot info.
     * @param robotName name of the robot
     * @param chassisName name of the chassis
     * @param shieldName name of the shield
     * @param armamentName name of the armament
     */
    public NewRobotInfo(final String robotName, final String chassisName,
            final String shieldName, final String armamentName) {

        this.robotName = robotName;
        this.armament = armamentName;
        this.chassis = chassisName;
        this.shield = shieldName;
    }

    /**
     * Returns the name of the armament.
     * @return armament name of the armament
     */
    public String getArmamentName() {
        return armament;
    }

    /**
     * Returns the name of the chassis
     * @return chassis name of the chassis
     */
    public String getChassisName() {
        return chassis;
    }

    /**
     * Returns the name of the robot.
     * @return robotName name of the robot
     */
    public String getRobotName() {
        return robotName;
    }

    /**
     * Returns the name of the shield.
     * @return shield name of the shield.
     */
    public String getShieldName() {
        return shield;
    }

    /**
     * Overrides method equals.
     * @param obj to compare
     * @return boolean true or false
     */
    @Override
    public boolean equals(final Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        NewRobotInfo rInfo = (NewRobotInfo) obj;
        if (this.getRobotName().equals(rInfo.getRobotName())) {
            return true;
        }
        return false;
    }

    /**
     * Overrides method hashCode.
     * @return hash code
     */
    @Override
    public int hashCode() {
        int hash = 5;
        hash = 97 * hash + this.robotName.hashCode();
        return hash;
    }

    /**
     * Overrides method toString.
     * @return String representation of this instance.
     */
    @Override
    public String toString() {
        return String.format("Name: %s, Chassis: %s, Shield: %s, Armament: %s",
                this.getRobotName(), this.getChassisName(),
                this.getShieldName(), this.getArmamentName());
    }
}

